1 /*
2  * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
3  * Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation version 2.1 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18  *
19  * Described at ETSI EN 300 468 V1.11.1 (2010-04)
20  */
21 
22 /**
23  * @file desc_cable_delivery.h
24  * @ingroup descriptors
25  * @brief Provides the descriptors for the cable delivery system descriptor
26  * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
27  * @author Mauro Carvalho Chehab
28  * @author Andre Roth
29  *
30  * @par Relevant specs
31  * The descriptor described herein is defined at:
32  * - ETSI EN 300 468 V1.11.1 (2010-04)
33  *
34  * @par Bug Report
35  * Please submit bug reports and patches to linux-media@vger.kernel.org
36  */
37 
38 module libdvbv5_d.desc_cable_delivery;
39 
40 import libdvbv5_d.descriptors: dvb_desc;
41 import libdvbv5_d.dvb_fe: dvb_v5_fe_parms;
42 
43 extern (C):
44 
45 /**
46  * @struct dvb_desc_cable_delivery
47  * @ingroup descriptors
48  * @brief Structure containing the cable delivery system descriptor
49  *
50  * @param type			descriptor tag
51  * @param length		descriptor length
52  * @param next			pointer to struct dvb_desc
53  * @param frequency		frequency, converted to Hz.
54  * @param fec_outer		FEC outer (typically, Viterbi)
55  * @param modulation		modulation
56  * @param fec_inner		FEC inner (convolutional code)
57  * @param symbol_rate		symbol rate, converted to symbols/sec (bauds)
58  */
59 struct dvb_desc_cable_delivery
60 {
61     align (1):
62 
63     ubyte type;
64     ubyte length;
65     dvb_desc* next;
66 
67     uint frequency;
68 
69     union
70     {
71         align (1):
72 
73         ushort bitfield1;
74 
75         struct
76         {
77             import std.bitmanip : bitfields;
78             align (1):
79 
80             mixin(bitfields!(
81                 ushort, "fec_outer", 4,
82                 ushort, "reserved_future_use", 12));
83         }
84     }
85 
86     ubyte modulation;
87 
88     union
89     {
90         align (1):
91 
92         uint bitfield2;
93 
94         struct
95         {
96             import std.bitmanip : bitfields;
97             align (1):
98 
99             mixin(bitfields!(
100                 uint, "fec_inner", 4,
101                 uint, "symbol_rate", 28));
102         }
103     }
104 }
105 
106 // struct dvb_v5_fe_parms;
107 
108 /**
109  * @brief Initializes and parses the service location descriptor
110  * @ingroup descriptors
111  *
112  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
113  * @param buf	buffer containing the descriptor's raw data
114  * @param desc	pointer to struct dvb_desc to be allocated and filled
115  *
116  * This function initializes and makes sure that all fields will follow the CPU
117  * endianness. Due to that, the content of the buffer may change.
118  *
119  * Currently, no memory is allocated internally.
120  *
121  * @return On success, it returns the size of the allocated struct.
122  *	   A negative value indicates an error.
123  */
124 int dvb_desc_cable_delivery_init (
125     dvb_v5_fe_parms* parms,
126     const(ubyte)* buf,
127     dvb_desc* desc);
128 
129 /**
130  * @brief Prints the content of the service location descriptor
131  * @ingroup descriptors
132  *
133  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
134  * @param desc	pointer to struct dvb_desc
135  */
136 void dvb_desc_cable_delivery_print (
137     dvb_v5_fe_parms* parms,
138     const(dvb_desc)* desc);
139 
140 /**
141  * @brief converts from the descriptor's modulation into enum fe_modulation,
142  *	  as defined by DVBv5 API.
143  */
144 extern __gshared const(uint)[] dvbc_modulation_table;
145 
146 /**
147  * @brief converts from the descriptor's FEC into enum fe_code_rate,
148  *	  as defined by DVBv5 API.
149  */
150 extern __gshared const(uint)[] dvbc_fec_table;